home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2332 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.7 KB

  1. Path: news1.h1.usa.pipeline.com!usenet
  2. From: grantp@usa.pipeline.com(Pete)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Help! Need a circle function taking float angle arguements
  5. Date: 17 Jan 1996 00:37:53 GMT
  6. Organization: Kalevi, Inc.
  7. Message-ID: <4dhgd1$ao@news1.usa.pipeline.com>
  8. NNTP-Posting-Host: pipe4.h1.usa.pipeline.com
  9. X-PipeUser: grantp
  10. X-PipeHub: usa.pipeline.com
  11. X-PipeGCOS: (Pete)
  12. X-Newsreader: Pipeline USA v3.3.0
  13.  
  14. On Jan 16, 1996 18:43:10 in article <Help! Need a circle function taking
  15. float angle arguements>, 'Dave Nulton <dnult@axiom.net>' wrote: 
  16.  
  17.  
  18. >I need a function that plots a circle on the screen in Borland  
  19. >Turbo C++.  The graphics.h file contains a function circle that  
  20. >takes an int x and y origin and int start and end angles.  The  
  21. >problem is that I need float start and end angles. 
  22. >I figure I can write a function using the putpixel function.   
  23. >However, being an inexperienced programmer, I would much perfer to  
  24. >find an existing library with the function I need. 
  25. >Does anyone know of such a library, or should I start writing that  
  26. >putpixel version 
  27.  
  28. What about converting your floats to integers?  If the library wants 
  29. angles based on 360 and your floats are also, it's a simple 
  30.  
  31. WARNING:  Untested code follows: 
  32.  
  33.    circlefunction(x, y, (int)fStartAngle, (int)fEndAngle); 
  34.  
  35. If your floats are based on radians, then do something like 
  36.  
  37.   inline int AngleComp (double x) 
  38.    {  const double factor = 360.0 / pi2; 
  39.        return (int)(x * factor); // use static_cast if supported 
  40.    } 
  41.  
  42. circle(x, y, AngleComp(start), AngleComp(end)); 
  43.   circle(x, y, (int)(strt * pi2 
  44.  
  45. -- 
  46. Pete Grant 
  47. Kalevi, Inc. 
  48. Object Oriented Software Development
  49.